package com.atguigu.edu2021.mock.service.impl;

import com.atguigu.edu2021.mock.bean.CourseInfo;
import com.atguigu.edu2021.mock.bean.OrderInfo;
import com.atguigu.edu2021.mock.mapper.OrderInfoMapper;
import com.atguigu.edu2021.mock.service.CourseInfoService;
import com.atguigu.edu2021.mock.service.OrderInfoService;
import com.atguigu.edu2021.mock.service.adv.impl.AdvServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 订单表 订单表 服务实现类
 * </p>
 *
 * @author zhangchen
 * @since 2021-09-05
 */
@Service
public class OrderInfoServiceImpl extends AdvServiceImpl<OrderInfoMapper, OrderInfo> implements OrderInfoService {


    @Autowired
    CourseInfoService courseInfoService;

    public List<CourseInfo> getOrderCourseList(Long userId){
        List<CourseInfo> courseInfoList=new ArrayList<>();
        List<Long> courseIdList = baseMapper.getOrderCourseIdList(userId);
        for (Long courseId : courseIdList) {
            CourseInfo courseInfo = courseInfoService.getById(courseId, true);
            courseInfoList.add(courseInfo);

        }
        return courseInfoList;

    }
}
